<!DOCTYPE html>
<html>
<head lang="zh-CN">
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="keywords" content="">
<meta name="description" content="">
<meta name="format-detection" content="telephone=no, email=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" href="<%=basePath%>favicon.ico" />

<script>
	var _provinceId = '';
	var isLogin = 'false' == 'true';
</script>

<title>订单详情</title>
<link rel="stylesheet" href="<%=basePath%>css/common/normalize.css">
<link rel="stylesheet" href="<%=basePath%>/css/user/login.css">
<link rel="stylesheet" href="<%=basePath%>css/common/iconfont.css">
</head>

<body>
	<div class="m-wrapper">

		<jsp:include page="header_member.jsp"></jsp:include>

		<div class="content box-tab" id="box-main">
			<div class="m-product">
				<dl class="lz-address">
					<dd class="addr-desc">
						<div>详情地址 ：${datas.dingDan.address}</div>
					</dd>
					<dd class="addr-tel">
						<div>手机/电话 ：${datas.dingDan.mobile}</div>
						<div>姓名 ：${datas.dingDan.name}</div>
					</dd>
				</dl>
			</div>
			<div class="m-product">

				<div class="product-bd">
					<ul class="product-list clear-fix">
						<c:forEach items="${datas.productList}" var="product">
							<div class="cart_list_item">
								<div class="cart_list_detail ">
									<div class="fl pl15">
										<span class="add_goods_img"><img title="" alt=""
											src="<%=imagePath %>${product.image}"></span>
									</div>
									<div class="fl">
										<a class="a-pro-name" href=""><p>${product.goodName}</p>
											<p>${product.pdt_spec}</p></a>
									</div>
									<div class="fl price">
										<strong>单价：<fmt:formatNumber value="${product.price}"
												pattern="#0.00" /></strong>
									</div>
									<div class="fl num">
										<span>数量：${product.count}</span>
									</div>
									<div class="fl total_prices">
										<span>金额：<fmt:formatNumber
												value="${product.count*product.price}" pattern="#0.00" /></span>
									</div>
								</div>
							</div>
						</c:forEach>
					</ul>
				</div>
			</div>

			<div class="m-product">
				<div class="lz-title mt20  lz-bottom-line">
					<h3>
						<i class="icon-uthink-01"></i>支付方式
					</h3>
				</div>
				<div class="lz-pay">
					<dl>
						<dd>
							<c:choose>
								<c:when test="${datas.dingDan.zf_type==2}">微信支付</c:when>
								<c:when test="${datas.dingDan.zf_type==0}">线下支付</c:when>
							</c:choose>
						</dd>
					</dl>
				</div>
			</div>

			<div class="m-product">
				<span id="goods_counts" class="notice">${fn:length(datas.productList)}</span>
				件商品 应付金额 合计： <span id="total_prices" class="notice">￥<fmt:formatNumber
						value="${datas.dingDan.money}" pattern="#0.00" /></span>
			</div>

			<!--正文:end-->
			<c:choose>
				<c:when
					test="${datas.dingDan.zf_type==2&&datas.dingDan.zi_status==0}">
					<div id="box-footer" class="m-footer box-tab">
						<button type="button"
							onclick="pay('${datas.dingDan.titles}','${datas.dingDan.money}')">确认支付</button>
					</div>
				</c:when>
				<c:when test="${datas.dingDan.dd_status==2}">
					<div id="box-footer" class="m-footer box-tab">
						<button type="button" onclick="receive(${datas.dingDan.rid})">收货</button>
					</div>
				</c:when>
			</c:choose>
		</div>
	</div>

	<style>
.tc_loading {
	z-index: 9998;
	width: 36%;
	height: 60px;
	text-align: center;
	border-radius: 5px;
	position: fixed;
	top: 50%;
	left: 50%;
	margin-top: -35px;
	margin-left: -18%;
	font-size: 14px;
	color: #fff;
	background-color: rgba(0, 0, 0, .7);
	padding-top: 10px;
	display: none;
}
</style>

	<script type="text/javascript" src="<%=basePath%>js/zepto.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/util.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/head.js"></script>
	<script type="text/javascript" src="<%=basePath%>/views/js/weixin.js"></script>
	<script type="text/javascript">
	
	function pay(title,money){
		/* alert(title+"**"+money); */
		$.ajax({
			url : "<%=basePath%>mobile/payConfig",
				data : {
					ordertitle : title,
					total : money
				},
				dataType : "json",
				success : function(jsapi) {
					if (jsapi.error == "1111") {
						alert(jsapi.information);
					} else {
						WeixinJSBridge.invoke('getBrandWCPayRequest', {
							"appId" : jsapi.appId, // 公众号名称，由商户传入
							"timeStamp" : jsapi.timeStamp, // 时间戳，自1970 年以来的秒数
							"nonceStr" : jsapi.nonceStr, // 随机串
							"package" : jsapi.package, // 预支付ID
							"signType" : jsapi.signType, // 微信签名方式:
							"paySign" : jsapi.paySign
						// 微信签名
						}, function(res) {
							if (res.err_msg == "get_brand_wcpay_request:ok") {
								alert("支付成功");
								location.href = "<%=basePath%>mobile/my_orders"; 
							}
						});
					}
				}
			});
		}
	
	function receive(id){
		$.ajax({
			type:"post",
			url:"<%=basePath%>user/updateOrder",
					data : "id=" + id
							+ "&dd_status=6&enable=5",
					success : function(msg) {
						var info = eval('(' + msg + ')');
						alert(info.information);
						window.location.reload();
					}
				})
	}
	</script>
</body>
</html>